package com.ruoyi.web.controller.tongban;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tongban.domain.UsrParentalChild;
import com.ruoyi.tongban.service.IUsrParentalChildService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 家长-孩子关联Controller
 * 
 * @author ruoyi
 * @date 2021-08-02
 */
@RestController
@RequestMapping("/tongban/parentalChild")
public class UsrParentalChildController extends BaseController
{
    @Autowired
    private IUsrParentalChildService usrParentalChildService;

    /**
     * 查询家长-孩子关联列表
     */
    @PreAuthorize("@ss.hasPermi('tongban:parentalChild:list')")
    @GetMapping("/list")
    public TableDataInfo list(UsrParentalChild usrParentalChild)
    {
        startPage();
        List<UsrParentalChild> list = usrParentalChildService.selectUsrParentalChildList(usrParentalChild);
        return getDataTable(list);
    }

    /**
     * 导出家长-孩子关联列表
     */
    @PreAuthorize("@ss.hasPermi('tongban:parentalChild:export')")
    @Log(title = "家长-孩子关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(UsrParentalChild usrParentalChild)
    {
        List<UsrParentalChild> list = usrParentalChildService.selectUsrParentalChildList(usrParentalChild);
        ExcelUtil<UsrParentalChild> util = new ExcelUtil<UsrParentalChild>(UsrParentalChild.class);
        return util.exportExcel(list, "parentalChild");
    }

    /**
     * 获取家长-孩子关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('tongban:parentalChild:query')")
    @GetMapping(value = "/{parentalChildId}")
    public AjaxResult getInfo(@PathVariable("parentalChildId") Long parentalChildId)
    {
        return AjaxResult.success(usrParentalChildService.selectUsrParentalChildById(parentalChildId));
    }

    /**
     * 新增家长-孩子关联
     */
    @PreAuthorize("@ss.hasPermi('tongban:parentalChild:add')")
    @Log(title = "家长-孩子关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UsrParentalChild usrParentalChild)
    {
        return toAjax(usrParentalChildService.insertUsrParentalChild(usrParentalChild));
    }

    /**
     * 修改家长-孩子关联
     */
    @PreAuthorize("@ss.hasPermi('tongban:parentalChild:edit')")
    @Log(title = "家长-孩子关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UsrParentalChild usrParentalChild)
    {
        return toAjax(usrParentalChildService.updateUsrParentalChild(usrParentalChild));
    }

    /**
     * 删除家长-孩子关联
     */
    @PreAuthorize("@ss.hasPermi('tongban:parentalChild:remove')")
    @Log(title = "家长-孩子关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{parentalChildIds}")
    public AjaxResult remove(@PathVariable Long[] parentalChildIds)
    {
        return toAjax(usrParentalChildService.deleteUsrParentalChildByIds(parentalChildIds));
    }
}
